[% setvar title docs/pdds/pdd17_basic_types.pod - Document parrot's basic PMC types %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='NAME'></a><h1>NAME</h1>
<p>docs/pdds/pdd17_basic_types.pod - Document parrot's basic PMC types</p>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>This PDD documents the base Parrot PMC types and their behaviours.</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>Parrot has a number of basic PMC types that all programs can guarantee
will be available to them. (With the possible exception of parrot
programs executing on an embedded device or other restricted environment)</p>
<a name='Scalar types'></a><h2>Scalar types</h2>
<ul>
<li><a name='Undef'></a>Undef</li>
<p>This is the generic no-value type. It has a numeric value of zero, a
string value of empty string, and a boolean value of false. It will,
on assignment, turn itself into a PMC of the source type, or if
assigned a basic type will turn itself into one of the wrapper PMC
types (detailed below) for the basic types.</p>
<li><a name='Integer'></a>Integer</li>
<p>The PMC wrapper for Parrot's low-level integer type. Always an
integer, with other types auto-converted to an integer when stored
into this PMC. The range and behaviour of the Integer PMC is
identical to the platform low-level integer.</p>
<p>The boolean value for an Integer is false if zero, otherwise true.</p>
<p>Floating point, string, and bignum values assigned to an Integer PMC
round to the nearest integer. Floats, or strings which resolve to
numbers, cap at the platform maximum or minimum integer value.</p>
<p>Integer PMCs take on a value of 1 if a boolean true is assigned, and
a value of 0 if a boolean false is assigned.</p>
<p>If an out-of-range value is assigned to an Integer PMC, the PMC will
throw an exception if exact math is enaabled.</p>
<li><a name='Float'></a>Float</li>
<p>The PMC wrapper for Parrot's low-level floating point type. Always a
float, with other types autoconverted to a float when stored into this
PMC.</p>
<p>The boolean value for a Float is false if exactly zero, otherwise
true.</p>
<p>When converted to an integer, floats round to the closest integer,
capping at the platform maximum or minimum integer value.</p>
<p>When converting to a string, floats use the platform default snprintf
format.</p>
<li><a name='String'></a>String</li>
<p>The PMC wrapper for Parrot's low-level string type. Always a simple
string, with other types autoconverted to a string when stored into
this PMC.</p>
<p>The boolean value for a String is false if empty or the string '0' (a
one character string holding a zero) otherwise true. This PMC
autoconverts to an integer or float when its integer or float value is
fetched.</p>
<li><a name='Boolean'></a>Boolean</li>
<p>The PMC wrapper for Parrot's low-level true/false value. Returns 0 for
false, 1 for true when fetched as an integer or float, empty string
for false and '1' for true when fetched as a string.</p>
<li><a name='BigNum'></a>BigNum</li>
<p>The PMC wrapper for Parrot's low-level BigNum type.</p>
<li><a name='ParrotClass'></a>ParrotClass</li>
<p>The PMC for Parrot's class. (Note that this may go away if we
ultimately make all classes just objects)</p>
<li><a name='ParrotObject'></a>ParrotObject</li>
<p>The PMC for Parrot's base object type.</p>
<li><a name='Reference'></a>Reference</li>
<p>The PMC that represents a reference to another PMC. Delegates all
functions to the referred-to PMC.</p>
</ul>
<a name='Array types'></a><h2>Array types</h2>
<p>Note that for the following types you can set the size of the array by
using the VTABLE_set_integer_native() method. Assigning an integer to
the array as a whole sets the array to that size.</p>
<p>Note that size-changing operations, such as push, pop, shift, unshift,
and splice, on fixed arrays will result in an exception.</p>
<ul>
<li><a name='FixedBooleanArray'></a>FixedBooleanArray</li>
<p>A statically sized array which holds only Boolean values.</p>
<li><a name='ResizeableBooleanArray'></a>ResizeableBooleanArray</li>
<p>A dynamically sized array which holds only Boolean values.</p>
<li><a name='FixedIntegerArray'></a>FixedIntegerArray</li>
<p>A statically sized array which holds only Integer values.</p>
<li><a name='ResizeableIntegerArray'></a>ResizeableIntegerArray</li>
<p>A dynamically sized array which holds only Integer values.</p>
<li><a name='FixedFloatArray'></a>FixedFloatArray</li>
<p>A statically sized array which holds only Float values.</p>
<li><a name='ResizeableFloatArray'></a>ResizeableFloatArray</li>
<p>A dynamically sized array which holds only Float values.</p>
<li><a name='FixedPMCArray'></a>FixedPMCArray</li>
<p>A statically sized array which holds only PMC values.</p>
<li><a name='ResizeablePMCArray'></a>ResizeablePMCArray</li>
<p>A dynamically sized array which holds only PMC values.</p>
<li><a name='FixedStringArray'></a>FixedStringArray</li>
<p>A statically sized array which holds only String values.</p>
<li><a name='ResizeableStringArray'></a>ResizeableStringArray</li>
<p>A dynamically sized array which holds only String values.</p>
</ul>
<a name='Hash types'></a><h2>Hash types</h2>
<ul>
<li><a name='Env'></a>Env</li>
<p>Env is a singleton PMC class, that is there is only one Env PMC in any
interpreter. This PMC gives access to the process' environment
variables--reading from it returns the value of the named process
environment variable, while writing to it sets the value of a process
environment variable. For example, to retrieve the current value of
TERM (the terminal type on most Unix systems):</p>
<pre>   new P1, .Env
   set S1, P1['TERM']</pre>
<p>Note that an embedding system may override this behaviour.</p>
</ul>
<a name='Binary Math operations'></a><h2>Binary Math operations</h2>
<p>The following is a list of what should happen with the basic types
when used in a binary math operation:</p>
<ul>
<li><a name='Integer x Integer'></a>Integer x Integer</li>
<p>The operation is an integer.</p>
</ul>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<a name='FOOTNOTES'></a><h1>FOOTNOTES</h1>
<p>List of footnotes to the text.</p>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<a name='VERSION'></a><h1>VERSION</h1>
<a name='CURRENT'></a><h2>CURRENT</h2>
<pre>    Maintainer: Dan Sugalski
    Class: Internals
    PDD Number: 17
    Version: 1.0
    Status: Developing
    Last Modified: 2004/06/11
    PDD Format: 1
    Language: English</pre>
<a name='HISTORY'></a><h2>HISTORY</h2>
<ul>
<li><a name='version 1'></a>version 1</li>
<p>None. First version</p>
</ul>
<a name='CHANGES'></a><h1>CHANGES</h1>
<ul>
<li><a name='Version 1.0'></a>Version 1.0</li>
<p>None. First version</p>
</ul>
</div>
